﻿using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using System.Collections.Generic;
using UnityEngine.UI;

public class UIHelper : MonoBehaviour
{
    /// <summary>
    /// 是否点击了gui对象
    /// </summary>
    /// <param name="raycaster"></param>
    /// <returns></returns>
    public static bool IsRaycastGUIObjects(GraphicRaycaster raycaster)
    {
        PointerEventData eventData = new PointerEventData(EventSystem.current);
        eventData.pressPosition = Input.mousePosition;
        eventData.position = Input.mousePosition;

        List<RaycastResult> list = new List<RaycastResult>();
        raycaster.Raycast(eventData, list);
        //Debug.Log(list.Count);
        return list.Count > 0;
    }
}
